package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyInterest;
import com.laowang.project.system.service.MyInterestService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 我的兴趣Controller
 *
 * @author laowang
 * @date 2023-04-27
 */
@Api(tags = "我的兴趣接口")
@RestController
@RequestMapping("/interest")
public class MyInterestController extends BaseController {
    @Autowired
    private MyInterestService myInterestService;

    @ApiOperation(value = "小程序端 查询兴趣列表",notes = "")
    @GetMapping("/web/list")
    public AjaxResult list() {

        List<MyInterest> list = myInterestService.selectMyInterestList(null);
        return AjaxResult.success("操作成功",list);
    }


    /**
     * 查询我的兴趣列表
     */
    @ApiOperation(value = "查询我的兴趣列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyInterest myInterest) {
        startPage();
        List<MyInterest> list = myInterestService.selectMyInterestList(myInterest);
        return getDataTable(list);
    }

    /**
     * 导出我的兴趣列表
     */
    @ApiOperation(value = "导出我的兴趣列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:export')")
    @Log(title = "我的兴趣", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyInterest myInterest) {
        List<MyInterest> list = myInterestService.selectMyInterestList(myInterest);
        ExcelUtil<MyInterest> util = new ExcelUtil<MyInterest>(MyInterest.class);
        return util.exportExcel(list, "interest");
    }

    /**
     * 获取我的兴趣详细信息
     */
    @ApiOperation(value = "获取我的兴趣详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myInterestService.selectMyInterestById(id));
    }

    /**
     * 新增我的兴趣
     */
    @ApiOperation(value = "新增我的兴趣",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:add')")
    @Log(title = "我的兴趣", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyInterest myInterest) {
        return toAjax(myInterestService.insertMyInterest(myInterest));
    }

    /**
     * 修改我的兴趣
     */
    @ApiOperation(value = "修改我的兴趣",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:edit')")
    @Log(title = "我的兴趣", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyInterest myInterest) {
        return toAjax(myInterestService.updateMyInterest(myInterest));
    }

    /**
     * 删除我的兴趣
     */
    @ApiOperation(value = "删除我的兴趣",notes = "")
    @PreAuthorize("@ss.hasPermi('system:interest:remove')")
    @Log(title = "我的兴趣", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myInterestService.deleteMyInterestByIds(ids));
    }
}
